package com.zhuoya.healthcard;

import android.widget.*;
import android.content.*;

import java.util.*;

import android.os.*;
import android.view.*;

import java.io.*;

import android.graphics.*;

public class ErrorActivity extends BaseActity {
    private Boolean A;
    private int code;
    private String errorInfo;
    private ImageView imageView;
    private TextView mErrorInfo;
    private TextView mTimeCount;
    private Integer pageStatus;
    private TextView retry;
    private CountDownTimer timer;

    public ErrorActivity() {
        this.A = true;
    }

    private void startCount() {
        this.timer = new CountDownTimer(10000L, 1000L) {
            public void onFinish() {
                ErrorActivity.this.startActivity(new Intent((Context) ErrorActivity.this, MainActivity.class));
                ErrorActivity.this.finish();
            }

            public void onTick(final long n) {
                ErrorActivity.this.mTimeCount.setText((CharSequence) String.format(Locale.CHINA, "%ds", n / 1000L));
            }
        }.start();
    }

    @Override
    protected void onCreate(final Bundle bundle) {
        super.onCreate(bundle);
        final Intent intent = this.getIntent();
        this.pageStatus = intent.getIntExtra("pageStatus", 1);
        this.code = intent.getIntExtra("code", 1);
        this.errorInfo = intent.getStringExtra("errorInfo");
        this.setContentView(R.layout.activity_error);
        this.mTimeCount = this.findViewById(R.id.timeCount);
        this.imageView = this.findViewById(R.id.imageView8);
        this.mErrorInfo = this.findViewById(R.id.textView15);
        final String errorInfo = this.errorInfo;
        if (errorInfo != null) {
            this.mErrorInfo.setText((CharSequence) errorInfo);
        }
        this.retry = this.findViewById(R.id.textView12);
        Bitmap imageBitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.error);
        final int code = this.code;
        if (code == 1) {
            this.retry.setVisibility(View.INVISIBLE);
        } else if (code == 2) {
            imageBitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.not_in_appoint_time);
            this.mErrorInfo.setText((CharSequence) "亲，请在预约的时间段取号");
            this.retry.setVisibility(View.INVISIBLE);
        } else if (code == 3) {
            imageBitmap = BitmapFactory.decodeResource(this.getResources(), 2131165321);
        } else if (code == 4) {
            imageBitmap = BitmapFactory.decodeResource(this.getResources(), R.drawable.wifi_error);
            this.mErrorInfo.setText((CharSequence) "网络异常");
        }
        this.imageView.setImageBitmap(imageBitmap);
        this.startCount();
        this.retry.setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                try {
                    final Intent intent = new Intent((Context) ErrorActivity.this, ScanCardActivity.class);
                    intent.putExtra("pageStatus", (Serializable) ErrorActivity.this.pageStatus);
                    ErrorActivity.this.startActivity(intent);
                    ErrorActivity.this.finish();
                } catch (Exception ex) {
                }
            }
        });
        this.findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                try {
                    ErrorActivity.this.startActivity(new Intent((Context) ErrorActivity.this, MainActivity.class));
                    ErrorActivity.this.finish();
                } catch (Exception ex) {
                }
            }
        });
        this.findViewById(R.id.backTV).setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                try {
                    ErrorActivity.this.startActivity(new Intent((Context) ErrorActivity.this, MainActivity.class));
                    ErrorActivity.this.finish();
                } catch (Exception ex) {
                }
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.A = false;
        final CountDownTimer timer = this.timer;
        if (timer != null) {
            timer.cancel();
        }
    }
}
